﻿
Imports DnnSecurity
Imports DnnSecurity.Passwords

Partial Class UserList
    Inherits DetailControl

    Class UserItem

        Private _UserName As String
        Public Property UserName() As String
            Get
                Return _UserName
            End Get
            Set(ByVal value As String)
                _UserName = value
            End Set
        End Property


        Private _PasswordScore As Passwords.PasswordScore
        Public Property PasswordScore() As Passwords.PasswordScore
            Get
                Return _PasswordScore
            End Get
            Set(ByVal value As Passwords.PasswordScore)
                _PasswordScore = value
            End Set
        End Property


    End Class

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load



        Dim dt As System.Data.DataTable = Nothing

        If DetailControlParameter = "user" Then
            dt = PasswordValidator.GetUsersWithWeakPassword(0)
        ElseIf DetailControlParameter = "host" Then
            dt = PasswordValidator.GetUsersWithWeakPassword(1)
        End If

        Dim list As New List(Of UserItem)

        For Each row As DataRow In dt.Rows
            Dim userItem As New UserItem
            userItem.UserName = row("UserName")
            userItem.PasswordScore = row("PasswordStrength")

            list.Add(userItem)
        Next

        GridView1.DataSource = list
        GridView1.DataBind()
    End Sub


End Class
